package com.hgyc.mom.mes.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hgyc.mom.common.vo.Result;
import com.hgyc.mom.core.mybatis.QueryWrapperUtil;
import com.hgyc.mom.mes.entity.MesWorkshopProduct;
import com.hgyc.mom.mes.service.MesWorkshopProductService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 关联产品Controller
 *
 * @author fwj
 * @since 2025-06-23
 */
@Tag(name = "关联产品控制器", description = "关联产品控制器")
@RestController
@RequestMapping("/mes/workshop/product")
public class MesWorkshopProductController {
    @Autowired
    private MesWorkshopProductService mesWorkshopProductService;


    @Operation(summary = "查询关联产品树列表", description = "查询关联产品树列表")
    @PostMapping("/list")
    public Result<List<MesWorkshopProduct>> pageList(@Parameter(description = "查询参数") @RequestBody MesWorkshopProduct mesWorkshopProduct) {
        QueryWrapper<MesWorkshopProduct> wrapper = QueryWrapperUtil.build(mesWorkshopProduct);
        List<MesWorkshopProduct> list = mesWorkshopProductService.list(wrapper);
        return Result.success(list);
    }

    @Operation(summary = "获取关联产品详细信息", description = "获取关联产品详细信息")
    @GetMapping(value = "/{id}")
    public Result getInfo(@Parameter(description = "关联产品ID") @PathVariable("id") Long id) {
        return Result.success(mesWorkshopProductService.getById(id));
    }

}